package com.mango.leet.code.easy;

import java.util.ArrayList;
import java.util.List;

/**
 * https://leetcode.cn/problems/pascals-triangle/
 * 118. 杨辉三角
 * @author mango
 * @since 2023-12-10
 */
public class LC118_PascalsTriangle {
    public List<List<Integer>> generate(int numRows) {
        List<List<Integer>> list = new ArrayList<>();
        for (int i = 0; i < numRows; i++) {
            List<Integer> list1 = new ArrayList<>();
            for (int j = 0; j <= i; j++) {
                if (j == 0 || j == i) {
                    list1.add(1);
                } else {
                    list1.add(list.get(i - 1).get(j - 1) + list.get(i - 1).get(j));
                }
            }
            list.add(list1);
        }
        return list;
    }
    public static void main(String[] args) {
        List<List<Integer>> list = new LC118_PascalsTriangle().generate(100);
        // 打印结果
        for (List<Integer> list1 : list) {
            for (Integer integer : list1) {
                System.out.print(integer + " ");
            }
            System.out.println();
        }
    }
}
